package shake.init;

import java.lang.annotation.Annotation;
import java.util.Properties;

import shake.annotation.Install;

public class InstallImpl implements Install {
	Properties properties;
	Install install;
	Class stereoType;

	public InstallImpl(Properties properties, Install install, Class stereoType) {
		this.properties = properties;
		this.install = install;
		this.stereoType = stereoType;
	}

	public boolean install() {
		if (stereoType != null
				&& properties.containsKey(stereoType.getName() + ".install")) {
			return Boolean.valueOf((String) properties.get(stereoType.getName()
					+ ".install"));
		}

		return install.install();
	}

	public int precedence() {
		if (stereoType != null
				&& properties.containsKey(stereoType.getName() + ".precedence")) {
			return Integer.valueOf((String) properties.get(stereoType.getName()
					+ ".precedence"));
		}

		return install.precedence();
	}

	public Class<? extends Annotation> annotationType() {
		return Install.class;
	}

}
